﻿-- Create table 应用信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_application') and type = 'U')
   drop table t_sys_application
go
create table t_sys_application
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  Numbers                   varchar(20),
  Path                      varchar(200),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
)
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@value = N'应用信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'Name',@value = N'应用名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'Numbers',@value = N'应用编号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'Path',@value = N'应用路径',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_application',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_application add constraint t_sys_application_pk primary key (ID)
go

-- Create/Recreate indexes
create unique index t_sys_application_idx1 on t_sys_application (Numbers)
go


-- Create table 行政区划信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_area') and type = 'U')
   drop table t_sys_area
go
create table t_sys_area
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  SortName                  varchar(10),
  Numbers                   varchar(20),
  ParentId                  varchar(50),
  Levels                    int,
  Code                      varchar(5),
  FullCode                  varchar(max),
  Spelling                  varchar(100),
  SimpleSpelling            varchar(50),
  Longitude                 decimal(20,8),
  Latitude                  decimal(20,8),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@value = N'行政区划信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'Name',@value = N'行政区划名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'SortName',@value = N'行政区划简称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'Numbers',@value = N'行政区划编号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'ParentId',@value = N'上级行政区划ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'Levels',@value = N'行政区划级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'Code',@value = N'行政区划编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'FullCode',@value = N'行政区划全编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'Spelling',@value = N'行政区划拼音',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'SimpleSpelling',@value = N'行政区划简拼',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'Longitude',@value = N'经度',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'Latitude',@value = N'纬度',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_area',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_area add constraint t_sys_area_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_area_idx1 on t_sys_area (Code);
create index t_sys_area_idx2 on t_sys_area (ParentId);
go


-- Create table 业务模型
if exists (select 1 from  sysobjects where  id = object_id('t_sys_biz_model') and type = 'U')
   drop table t_sys_biz_model
go
create table t_sys_biz_model
(
  ID                        varchar(50) not null,
  Name                      varchar(100),
  ClassName                 varchar(50),
  ClassFullName             varchar(100),
  AssemblyName              varchar(50),
  ClassifyId		        varchar(50),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@value = N'业务模型',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'Name',@value = N'业务模型名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'ClassName',@value = N'业务模型类名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'ClassFullName',@value = N'业务模型类全名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'AssemblyName',@value = N'程序集名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'ClassifyId',@value = N'所属业务模型分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_biz_model add constraint t_sys_biz_model_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_biz_model_idx1 on t_sys_biz_model (AssemblyName, ClassName);
create index t_sys_biz_model_idx2 on t_sys_biz_model (ClassifyId);
create index t_sys_biz_model_idx3 on t_sys_biz_model (Name);
go


-- Create table 业务模型分类信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_biz_model_classify') and type = 'U')
   drop table t_sys_biz_model_classify
go
create table t_sys_biz_model_classify
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  ParentId                  varchar(50),
  Levels                    int,
  Code                      varchar(4),
  FullCode                  varchar(max),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@value = N'业务模型分类信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

--Add comments to the columns
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'Name',@value = N'分类名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'ParentId',@value = N'上级分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'Levels',@value = N'分类级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'Code',@value = N'分类编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'FullCode',@value = N'分类全编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_classify',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_biz_model_classify add constraint t_sys_biz_model_classify_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_biz_model_classify_idx1 on t_sys_biz_model_classify (Code);
create index t_sys_biz_model_classify_idx2 on t_sys_biz_model_classify (ParentId);
go


-- Create table 业务模型属性
if exists (select 1 from  sysobjects where  id = object_id('t_sys_biz_model_property') and type = 'U')
   drop table t_sys_biz_model_property
go
create table t_sys_biz_model_property
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  BizModelId                varchar(50),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(500)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@value = N'业务模型属性',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

--Add comments to the columns
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'Name',@value = N'属性名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'BizModelId',@value = N'所属业务模型ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_property',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_biz_model_property add constraint t_sys_biz_model_property_pk primary key (ID);
go

-- Create/Recreate indexes
create index t_sys_biz_model_property_idx1 on t_sys_biz_model_property (BizModelId);
create index t_sys_biz_model_property_idx2 on t_sys_biz_model_property (Name);
create index t_sys_biz_model_property_idx3 on t_sys_biz_model_property (Remarks);
go


-- Create table 业务模型视图
if exists (select 1 from  sysobjects where  id = object_id('t_sys_biz_model_view') and type = 'U')
   drop table t_sys_biz_model_view
go
create table t_sys_biz_model_view
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  ConditionTypeId           int,
  IsIncludePartJob          bit,
  Content                   varchar(4000),
  BizModelId                varchar(50),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@value = N'业务模型视图',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'Name',@value = N'视图名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'ConditionTypeId',@value = N'条件类型ID:0=所有数据;1=当前用户;2=当前部门;3=当前部门以及子部门;4=当前机构;5=当前机构以及子机构;6=当前群组',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'IsIncludePartJob',@value = N'是否包含兼职',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'Content',@value = N'视图内容',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'BizModelId',@value = N'所属业务模型ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_model_view',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_biz_model_view add constraint t_sys_biz_model_view_pk primary key (ID);
go

-- Create/Recreate indexes
create index t_sys_biz_model_view_idx1 on t_sys_biz_model_view (BizModelId);
create index t_sys_biz_model_view_idx2 on t_sys_biz_model_view (Name);
go


-- Create table 业务参数信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_biz_param') and type = 'U')
   drop table t_sys_biz_param
go
create table t_sys_biz_param
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  Numbers                   varchar(50),
  ClassifyId		        varchar(50),
  ApplicationId             varchar(50),
  Value                     varchar(1000),  
  LayoutProportion          varchar(5),
  ControlType               int,
  Options                   varchar(1000),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@value = N'业务参数信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'Name',@value = N'业务参数名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'Numbers',@value = N'业务参数编号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'ClassifyId',@value = N'所属分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'ApplicationId',@value = N'所属应用ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'Value',@value = N'业务参数值',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'LayoutProportion',@value = N'布局占比',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'ControlType',@value = N'控件类型',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'Options',@value = N'选项',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_biz_param add constraint t_sys_biz_param_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_biz_param_idx1 on t_sys_biz_param (Numbers);
create index t_sys_biz_param_idx2 on t_sys_biz_param (Name);
go


-- Create table 业务参数分类信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_biz_param_classify') and type = 'U')
   drop table t_sys_biz_param_classify
go
create table t_sys_biz_param_classify
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  ApplicationId             varchar(50),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@value = N'业务参数分类信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'Name',@value = N'接口名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'ApplicationId',@value = N'所属应用ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_biz_param_classify',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_biz_param_classify add constraint t_sys_biz_param_classify_pk primary key (ID);
go


-- Create table 编码信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_code') and type = 'U')
   drop table t_sys_code
go
create table t_sys_code
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  Numbers                   varchar(20),
  ClassifyId				varchar(50),
  CurrentSerialNumber       int,
  CurrentValue              varchar(200),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@value = N'编码信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'Name',@value = N'编码名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'Numbers',@value = N'编号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'ClassifyId',@value = N'所属分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'CurrentSerialNumber',@value = N'当前序列号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'CurrentValue',@value = N'当前值',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_code add constraint t_sys_code_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_code_idx1 on t_sys_code (Numbers);
go


-- Create table 编码分类信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_code_classify') and type = 'U')
   drop table t_sys_code_classify
go
create table t_sys_code_classify
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  ParentId                  varchar(50),
  Levels                    int,
  Code                      varchar(4),
  FullCode                  varchar(max),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@value = N'编码分类信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'Name',@value = N'分类名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'ParentId',@value = N'上级分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'Levels',@value = N'编码分类级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'Code',@value = N'分类编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'FullCode',@value = N'分类全编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_classify',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_code_classify add constraint t_sys_code_classify_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_code_classify_idx1 on t_sys_code_classify (Code);
create index t_sys_code_classify_idx2 on t_sys_code_classify (ParentId);
go


-- Create table 编码规则
if exists (select 1 from  sysobjects where  id = object_id('t_sys_code_rule') and type = 'U')
   drop table t_sys_code_rule
go
create table t_sys_code_rule
(
  ID                        varchar(50) not null,
  CodeId                    varchar(50),
  TypeId                    int,
  Format                    varchar(50),
  InitialValue              int,
  Step                      int,  
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@value = N'编码规则',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'CodeId',@value = N'所属编码ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'TypeId',@value = N'类型ID:1=固定值;2=日期时间;3=机构;4=部门;5=用户;6=流水号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'Format',@value = N'格式',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'InitialValue',@value = N'初始值',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'Step',@value = N'步长',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_rule',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_code_rule add constraint t_sys_code_rule_pk primary key (ID);
go

-- Create/Recreate indexes
create index t_sys_code_rule_idx1 on t_sys_code_rule (CodeId);
go


-- Create table 编码种子信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_code_seed') and type = 'U')
   drop table t_sys_code_seed
go
create table t_sys_code_seed
(
  ID                        varchar(50) not null,
  CodeId                    varchar(50),
  SerialNumber              int,
  CodeValue                 varchar(200),
  ClientIpAddress           varchar(20),
  ClientName                varchar(50),
  IsUse                     bit,
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@value = N'编码种子信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'CodeId',@value = N'编码ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'SerialNumber',@value = N'流水号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'CodeValue',@value = N'编码值',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'ClientIpAddress',@value = N'客户端IP地址',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'ClientName',@value = N'客户端名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'IsUse',@value = N'是否使用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_code_seed',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_code_seed add constraint t_sys_code_seed_pk primary key (ID);
go

-- Create/Recreate indexes
create index t_sys_code_seed_idx1 on t_sys_code_seed (CodeId);
go


-- Create table 字典信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_dictionary') and type = 'U')
   drop table t_sys_dictionary
go
create table t_sys_dictionary
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  Numbers                   varchar(20),
  ClassifyId			    varchar(50),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@value = N'字典信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'Name',@value = N'字典名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'Numbers',@value = N'字典编号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'ClassifyId',@value = N'所属分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_dictionary add constraint t_sys_dictionary_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_dictionary_idx1 on t_sys_dictionary (Numbers);
go


-- Create table 字典分类信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_dictionary_classify') and type = 'U')
   drop table t_sys_dictionary_classify
go
create table t_sys_dictionary_classify
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  ParentId                  varchar(50),
  Levels                    int,
  Code                      varchar(4),
  FullCode                  varchar(max),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@value = N'字典分类信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'Name',@value = N'分类名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'ParentId',@value = N'上级分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'Levels',@value = N'字典分类级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'Code',@value = N'分类编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'FullCode',@value = N'分类全编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_classify',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_dictionary_classify add constraint t_sys_dictionary_classify_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_dictionary_classify_idx1 on t_sys_dictionary_classify (Code);
create index t_sys_dictionary_classify_idx2 on t_sys_dictionary_classify (ParentId);
go


-- Create table 字典内容
if exists (select 1 from  sysobjects where  id = object_id('t_sys_dictionary_content') and type = 'U')
   drop table t_sys_dictionary_content
go
create table t_sys_dictionary_content
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  Value                     varchar(50),
  ParentId                  varchar(50),
  Levels                    int,
  Code                      varchar(4),
  FullCode                  varchar(4000),
  DictionaryId              varchar(50),
  DictionaryNumbers         varchar(20),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@value = N'字典内容',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'Name',@value = N'字典内容名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'Value',@value = N'字典内容值',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'ParentId',@value = N'上级字典内容ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'Levels',@value = N'字典内容级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'Code',@value = N'字典内容编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'FullCode',@value = N'字典内容全编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'DictionaryId',@value = N'所属字典ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'DictionaryNumbers',@value = N'所属字典编号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_dictionary_content',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_dictionary_content add constraint t_sys_dictionary_content_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_dictionary_content_idx1 on t_sys_dictionary_content (DictionaryId, Value);
go


-- Create table 系统功能
if exists (select 1 from  sysobjects where  id = object_id('t_sys_function') and type = 'U')
   drop table t_sys_function
go
create table t_sys_function
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  ClassifyId				varchar(50),
  Content                   varchar(2000),
  ParentId                  varchar(50),
  IsSystem                  bit,
  IsPlatform                bit,
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@value = N'系统功能',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'Name',@value = N'功能名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'ClassifyId',@value = N'功能分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'Content',@value = N'功能内容',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'ParentId',@value = N'上级功能ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'IsSystem',@value = N'是否系统级',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'IsPlatform',@value = N'是否平台功能',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_function add constraint t_sys_function_pk primary key (ID);
go

-- Create/Recreate indexes
create index t_sys_function_idx1 on t_sys_function (ClassifyId);
create index t_sys_function_idx2 on t_sys_function (Name);
create index t_sys_function_idx3 on t_sys_function (IsPlatform);
go


-- Create table 功能分类信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_function_classify') and type = 'U')
   drop table t_sys_function_classify
go
create table t_sys_function_classify
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  ParentId                  varchar(50),
  Levels                    int,
  Code                      varchar(20),
  FullCode                  varchar(max),
  IsSystem                  bit,
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@value = N'字典分类信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'Name',@value = N'分类名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'ParentId',@value = N'上级分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'Levels',@value = N'分类级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'Code',@value = N'分类编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'FullCode',@value = N'分类全编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'IsSystem',@value = N'是否系统级',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_classify',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_function_classify add constraint t_sys_function_classify_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_function_classify_idx1 on t_sys_function_classify (Code);
go


-- Create table 业务功能元素
if exists (select 1 from  sysobjects where  id = object_id('t_sys_function_element') and type = 'U')
   drop table t_sys_function_element
go
create table t_sys_function_element
(
  ID                        varchar(50) not null,
  ElementId                 varchar(100),
  Name                      varchar(50),
  TypeId                    int,
  GridElementId             varchar(100),
  FunctionId                varchar(50),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@value = N'业务功能元素',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'ElementId',@value = N'元素ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'Name',@value = N'元素名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'TypeId',@value = N'元素类型:1=表单元素;2=列表元素',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'GridElementId',@value = N'列表元素ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'FunctionId',@value = N'所属功能ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_function_element',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_function_element add constraint t_sys_function_element_pk primary key (ID);
go

-- Create/Recreate indexes
create index t_sys_function_element_idx1 on t_sys_function_element (FunctionId);
create index t_sys_function_element_idx2 on t_sys_function_element (Name);
go


-- Create table 接口信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_interface') and type = 'U')
   drop table t_sys_interface
go
create table t_sys_interface
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  ClassifyId				varchar(50),
  InterfaceAssembly			varchar(100),
  InterfaceClass			varchar(200),
  ImplementAssembly			varchar(100),
  ImplementClass			varchar(200),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@value = N'接口信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'Name',@value = N'接口名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'ClassifyId',@value = N'所属分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'InterfaceAssembly',@value = N'接口程序集',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'InterfaceClass',@value = N'接口类',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'ImplementAssembly',@value = N'实现类程序集',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'ImplementClass',@value = N'实现类',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_interface add constraint t_sys_interface_pk primary key (ID);
go

-- Create/Recreate indexes
create index t_sys_interface_idx1 on t_sys_interface (ClassifyId);
create index t_sys_interface_idx2 on t_sys_interface (SortNumber);
go


-- Create table 接口分类信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_interface_classify') and type = 'U')
   drop table t_sys_interface_classify
go
create table t_sys_interface_classify
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  ParentId                  varchar(50),
  Levels                    int,
  Code                      varchar(4),
  FullCode                  varchar(max),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@value = N'web接口信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'Name',@value = N'分类名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'ParentId',@value = N'上级分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'Levels',@value = N'web接口级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'Code',@value = N'分类编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'FullCode',@value = N'分类全编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_interface_classify',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_interface_classify add constraint t_sys_interface_classify_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_interface_classify_idx1 on t_sys_interface_classify (Code);
create index t_sys_interface_classify_idx2 on t_sys_interface_classify (ParentId);
go


-- Create table 登录信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_login') and type = 'U')
   drop table t_sys_login
go
create table t_sys_login
(
  ID                    varchar(50) not null,
  ApplicationMark		varchar(50),
  ClientIPAddress       varchar(20),
  ClientName            varchar(200),
  Token					varchar(500),
  CreateUserAccount		varchar(50),
  CreateUserId			varchar(50),
  CreateUserName		varchar(100),
  CreateDepartmentId    varchar(50),
  CreateOrganizationId  varchar(50),
  CreateTime            datetime
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_login',@value = N'登录信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_login',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

exec sys.sp_addextendedproperty @level1name = N't_sys_login',@level2name = N'ApplicationMark',@value = N'应用标记',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_login',@level2name = N'ClientIPAddress',@value = N'客户端IP地址',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_login',@level2name = N'ClientName',@value = N'客户端名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_login',@level2name = N'Token',@value = N'Token',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

exec sys.sp_addextendedproperty @level1name = N't_sys_login',@level2name = N'CreateUserAccount',@value = N'创建人账号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_login',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_login',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_login',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_login',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_login',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_login add constraint t_sys_login_pk primary key (ID);
go

-- Create/Recreate indexes 
create index t_sys_login_idx0 on t_sys_login (CreateUserAccount);
create index t_sys_login_idx1 on t_sys_login (CreateUserId);
create index t_sys_login_idx2 on t_sys_login (CreateTime);
create index t_sys_login_idx3 on t_sys_login (ApplicationMark);
create index t_sys_login_idx4 on t_sys_login (ClientIPAddress);
create index t_sys_login_idx5 on t_sys_login (Token);
go


-- Create table 操作日志
if exists (select 1 from  sysobjects where  id = object_id('t_sys_log_operation') and type = 'U')
   drop table t_sys_log_operation
go
create table t_sys_log_operation
(
  ID                    varchar(50) not null,
  TypeId				int,
  IsSuccess				bit,
  FunctionId			varchar(50),
  ActionId				int,
  ActionObject			varchar(100),
  ActionObjectKeyValue	varchar(50),
  ActionMethod			varchar(200),
  ActionParameter		text,
  ActionUesTimes		bigint,
  Result				text,
  ClientIPAddress       varchar(20),
  ClientName            varchar(200),
  CreateUserAccount		varchar(50),
  CreateUserId			varchar(50),  
  CreateUserName		varchar(100),
  CreateDepartmentId    varchar(50),
  CreateOrganizationId  varchar(50),
  CreateTime            datetime
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@value = N'操作日志',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'TypeId',@value = N'操作类型ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'IsSuccess',@value = N'是否成功',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'FunctionId',@value = N'功能ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'ActionId',@value = N'操作行为id',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'ActionObject',@value = N'操作行为对象',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'ActionObjectKeyValue',@value = N'操作行为对象主键值',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'ActionMethod',@value = N'操作行为方法名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'ActionParameter',@value = N'操作行为参数',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'ActionUesTimes',@value = N'操作行为用时(毫秒)',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'Result',@value = N'操作结果',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'ClientIPAddress',@value = N'客户端IP地址',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'ClientName',@value = N'客户端名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'CreateUserAccount',@value = N'创建人账号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_log_operation',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_log_operation add constraint t_sys_log_operation_pk primary key (ID);
go

-- Create/Recreate indexes 
create index t_sys_log_operation_idx0 on t_sys_log_operation (CreateUserAccount);
create index t_sys_log_operation_idx1 on t_sys_log_operation (CreateUserId);
create index t_sys_log_operation_idx2 on t_sys_log_operation (ActionObjectKeyValue);
create index t_sys_log_operation_idx3 on t_sys_log_operation (CreateTime);
go


-- Create table 系统菜单
if exists (select 1 from  sysobjects where  id = object_id('t_sys_menu') and type = 'U')
   drop table t_sys_menu
go
create table t_sys_menu
(
  ID                        varchar(50) not null,
  Name                      varchar(50),  
  Levels                    int,  
  Icon                      varchar(50),  
  FunctionId                varchar(50),  
  ParentId                  varchar(50),
  IsSystem                  bit,
  Code                      varchar(4),
  FullCode                  varchar(max),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@value = N'系统菜单',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'Name',@value = N'菜单名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'Levels',@value = N'菜单级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'Icon',@value = N'菜单图标',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'FunctionId',@value = N'功能ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'ParentId',@value = N'上级菜单ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'IsSystem',@value = N'是否系统级',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'Code',@value = N'菜单编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'FullCode',@value = N'菜单全编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_menu',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_menu add constraint t_sys_menu_pk primary key (ID);
go

-- Create/Recreate indexes 
create unique index t_sys_menu_idx1 on t_sys_menu (Code);
create index t_sys_menu_idx2 on t_sys_menu (FunctionId);
create index t_sys_menu_idx3 on t_sys_menu (ParentId);
go


-- Create table 组织类型
if exists (select 1 from  sysobjects where  id = object_id('t_sys_organization_type') and type = 'U')
   drop table t_sys_organization_type
go
create table t_sys_organization_type
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  Numbers                   varchar(20),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@value = N'组织类型',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'Name',@value = N'组织类型名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'Numbers',@value = N'组织类型编号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_organization_type add constraint t_sys_organization_type_pk primary key (ID);
go

-- Create/Recreate indexes 
create unique index t_sys_organization_type_idx1 on t_sys_organization_type (Numbers);
create index t_sys_organization_type_idx2 on t_sys_organization_type (Name);
go


-- Create table 组织类型职务
if exists (select 1 from  sysobjects where  id = object_id('t_sys_organization_type_posi') and type = 'U')
   drop table t_sys_organization_type_posi
go
create table t_sys_organization_type_posi
(
  ID                        varchar(50) not null,
  OrganizationTypeId        varchar(50) not null,
  PositionId                varchar(50) not null
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type_posi',@value = N'组织类型职务',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type_posi',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type_posi',@level2name = N'OrganizationTypeId',@value = N'组织类型ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_type_posi',@level2name = N'PositionId',@value = N'职务ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go


-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_organization_type_posi add constraint organization_type_posi_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index organization_type_posi_idx1 on t_sys_organization_type_posi (OrganizationTypeId, PositionId);
go


-- Create table 组织单元
if exists (select 1 from  sysobjects where  id = object_id('t_sys_organization_unit') and type = 'U')
   drop table t_sys_organization_unit
go
create table t_sys_organization_unit
(
  ID                        varchar(50) not null,
  Name                      varchar(100),
  ShortName                 varchar(50),
  EnglishName               varchar(100),
  Numbers                   varchar(20),
  Levels                    int,
  PropertyId                int,
  OrganizationTypeId        varchar(50),
  IsIndependent             bit,
  ParentId                  varchar(50),
  OrganizationId            varchar(50),
  Code                      varchar(4),
  FullCode                  varchar(max),
  LeadPositionId            varchar(4000),
  AssistantPositionId       varchar(4000),
  Phone                     varchar(20),
  Contacter                 varchar(50),
  ProvinceId                varchar(50),
  CityId                    varchar(50),
  AreaId                    varchar(50),
  StreetId                  varchar(50),
  Address                   varchar(200),
  Longitude                 decimal(20,8),
  Latitude                  decimal(20,8),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@value = N'组织单元',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'Name',@value = N'组织单元名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'ShortName',@value = N'组织单元简称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'EnglishName',@value = N'组织单元英文名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'Numbers',@value = N'组织单元编号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'Levels',@value = N'组织单元级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'PropertyId',@value = N'组织单元性质ID:1=机构;2=部门',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'OrganizationTypeId',@value = N'组织单元类型ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'IsIndependent',@value = N'是否独立组织单元',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'ParentId',@value = N'上级组织单元ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'OrganizationId',@value = N'所属机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'Code',@value = N'组织单元编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'FullCode',@value = N'组织单元全编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'LeadPositionId',@value = N'负责人职务ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'AssistantPositionId',@value = N'助理职务ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'Phone',@value = N'联系电话',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'Contacter',@value = N'联系人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'ProvinceId',@value = N'所在省ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'CityId',@value = N'所在市ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'AreaId',@value = N'所在区县ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'StreetId',@value = N'所在街道ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'Address',@value = N'所在地址ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'Longitude',@value = N'经度',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'Latitude',@value = N'纬度',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_organization_unit add constraint t_sys_organization_unit_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_organization_unit_idx1 on t_sys_organization_unit (Code);
create index t_sys_organization_unit_idx2 on t_sys_organization_unit (ParentId);
create index t_sys_organization_unit_idx3 on t_sys_organization_unit (Name);
go


-- Create table 组织单元职务
if exists (select 1 from  sysobjects where  id = object_id('t_sys_organization_unit_posi') and type = 'U')
   drop table t_sys_organization_unit_posi
go
create table t_sys_organization_unit_posi
(
  ID                        varchar(50) not null,
  OrganizationUnitId        varchar(50) not null,
  PositionId                varchar(50) not null,
  PositionTitle	            varchar(50) null,
  PersonCount		        int null
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit_posi',@value = N'组织单元职务',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit_posi',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit_posi',@level2name = N'OrganizationUnitId',@value = N'组织单元ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit_posi',@level2name = N'PositionId',@value = N'职务ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit_posi',@level2name = N'PositionTitle',@value = N'职位名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_organization_unit_posi',@level2name = N'PersonCount',@value = N'人数',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_organization_unit_posi add constraint organization_unit_posi_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index organization_unit_posi_idx1 on t_sys_organization_unit_posi (OrganizationUnitId, PositionId);
create index organization_unit_posi_idx2 on t_sys_organization_unit_posi (PositionTitle);
go


-- Create table 分页设置信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_setting_page') and type = 'U')
   drop table t_sys_setting_page
go
create table t_sys_setting_page
(
  ID                        varchar(50) not null,
  FunctionId                varchar(50),
  GridId                    varchar(50),
  UserId                    varchar(50),
  PageSize                  int
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_setting_page',@value = N'分页设置信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_setting_page',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_setting_page',@level2name = N'FunctionId',@value = N'功能ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_setting_page',@level2name = N'GridId',@value = N'Grid控件ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_setting_page',@level2name = N'UserId',@value = N'用户ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_setting_page',@level2name = N'PageSize',@value = N'每页记录数',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_setting_page add constraint t_sys_setting_page_pk primary key (ID);
go

create unique index t_sys_setting_page_idx1 on t_sys_setting_page (FunctionId, GridId, UserId);
go


-- Create table 系统权限
if exists (select 1 from  sysobjects where  id = object_id('t_sys_permission') and type = 'U')
   drop table t_sys_permission
go
create table t_sys_permission
(
  ID                        varchar(50) not null,
  ObjectId                  varchar(50),
  ObjectTypeId              int,
  PermissionId              varchar(50),
  PermissionTypeId          int,
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@value = N'系统权限',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'ObjectId',@value = N'授权对象ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'ObjectTypeId',@value = N'授权对象类型ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'PermissionId',@value = N'权限对象ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'PermissionTypeId',@value = N'权限对象类型ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_permission',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_permission add constraint t_sys_permission_pk primary key (ID);
go

-- Create/Recreate indexes 
create unique index t_sys_permission_idx1 on t_sys_permission (ObjectId, PermissionId);
create index t_sys_permission_idx2 on t_sys_permission (PermissionTypeId);
go


-- Create table 职务信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_position') and type = 'U')
   drop table t_sys_position
go
create table t_sys_position
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  PositionTypeId            varchar(50) not null,
  Code                      varchar(4),  
  FullCode                  varchar(max),
  ParentId                  varchar(50),
  Levels                    int,
  GradeLevelsList           varchar(4000),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@value = N'职务信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'Name',@value = N'职务名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'PositionTypeId',@value = N'职类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'Code',@value = N'职务编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'FullCode',@value = N'职务全编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'ParentId',@value = N'上级职务ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'Levels',@value = N'职务级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'GradeLevelsList',@value = N'职级级别列表,";"号隔开',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_position add constraint t_sys_position_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_position_idx1 on t_sys_position (Code);
create index t_sys_position_idx2 on t_sys_position (ParentId);
create index t_sys_position_idx3 on t_sys_position (Name);
go


-- Create table 职务职级信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_position_grade') and type = 'U')
   drop table t_sys_position_grade
go
create table t_sys_position_grade
(
  ID                        varchar(50) not null,
  PositionId                varchar(50) not null,
  PositionTypeGradeId       varchar(50) not null
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_position_grade',@value = N'职务职级信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_position_grade',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_grade',@level2name = N'PositionId',@value = N'职务ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_grade',@level2name = N'PositionTypeGradeId',@value = N'职类职级ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_position_grade add constraint t_sys_position_grade_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_position_grade_idx1 on t_sys_position_grade (PositionId, PositionTypeGradeId);
go


-- Create table 职类信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_position_type') and type = 'U')
   drop table t_sys_position_type
go
create table t_sys_position_type
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  Label                     varchar(10),
  LevelsLower               int,
  LevelsUpper               int,
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@value = N'职类信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'Name',@value = N'职类名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'Label',@value = N'职类标记',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'LevelsLower',@value = N'职级下限',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'LevelsUpper',@value = N'职级上限',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_position_type add constraint t_sys_position_type_pk primary key (ID);
go


-- Create table 职类职级信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_position_type_grade') and type = 'U')
   drop table t_sys_position_type_grade
go
create table t_sys_position_type_grade
(
  ID                        varchar(50) not null,  
  Name                      varchar(50),
  PositionTypeId            varchar(50) not null,
  Label                     varchar(10),
  Levels                    int
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type_grade',@value = N'职类职级信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type_grade',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type_grade',@level2name = N'Name',@value = N'职级名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type_grade',@level2name = N'PositionTypeId',@value = N'职类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type_grade',@level2name = N'Label',@value = N'职类标记',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_position_type_grade',@level2name = N'Levels',@value = N'职级级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_position_type_grade add constraint position_category_type_pk primary key (ID);
go

-- Create/Recreate indexes
create index position_category_type_idx1 on t_sys_position_type_grade (PositionTypeId);
create index position_category_type_idx2 on t_sys_position_type_grade (Levels);
go


-- Create table 角色信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_role') and type = 'U')
   drop table t_sys_role
go
create table t_sys_role
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  Numbers                   varchar(20),
  ClassifyId				varchar(50),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@value = N'角色信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'Name',@value = N'角色名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'Numbers',@value = N'角色编号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'ClassifyId',@value = N'所属分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_role add constraint t_sys_role_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_role_idx1 on t_sys_role (Numbers);
create index t_sys_role_idx2 on t_sys_role (SortNumber);
create index t_sys_role_idx3 on t_sys_role (Name);
go


-- Create table 角色分类信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_role_classify') and type = 'U')
   drop table t_sys_role_classify
go
create table t_sys_role_classify
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  ParentId                  varchar(50),
  Levels                    int,
  Code                      varchar(4),
  FullCode                  varchar(max),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@value = N'角色分类信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'Name',@value = N'分类名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'ParentId',@value = N'上级分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'Levels',@value = N'分类级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'Code',@value = N'分类编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'FullCode',@value = N'分类全编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_classify',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_role_classify add constraint t_sys_role_classify_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_role_classify_idx1 on t_sys_role_classify (Code);
create index t_sys_role_classify_idx2 on t_sys_role_classify (ParentId);
go


-- Create table 角色用户
if exists (select 1 from  sysobjects where  id = object_id('t_sys_role_user') and type = 'U')
   drop table t_sys_role_user
go
create table t_sys_role_user
(
  ID                        varchar(50) not null,
  RoleId                    varchar(50),
  UserId					varchar(50),
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_role_user',@value = N'角色用户',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_role_user',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_user',@level2name = N'RoleId',@value = N'角色ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_user',@level2name = N'UserId',@value = N'用户ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_role_user',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_user',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_user',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_user',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_role_user',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_role_user add constraint t_sys_role_user_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_role_user_idx1 on t_sys_role_user (RoleId, UserId);
create index t_sys_role_user_idx2 on t_sys_role_user (RoleId);
create index t_sys_role_user_idx3 on t_sys_role_user (UserId);
go


-- Create table 用户信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_user') and type = 'U')
   drop table t_sys_user
go
create table t_sys_user
(
  ID                        varchar(50) not null,
  Account                   varchar(10) not null,
  Name                      varchar(100),
  GenderId                  int,
  SecretKey                 varchar(100),
  Password                  varchar(100),
  Mobile                    varchar(20),
  Email                     varchar(50),
  IsAdmin                   bit,
  PositionId                varchar(50),
  PositionTypeGradeId       varchar(50),
  DepartmentId              varchar(50),
  OrganizationId            varchar(50),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@value = N'用户信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'Account',@value = N'账号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'Name',@value = N'姓名',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'GenderId',@value = N'性别ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'SecretKey',@value = N'密钥:用来创建密码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'Password',@value = N'密码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'Mobile',@value = N'手机号码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'Email',@value = N'电子邮件',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'IsAdmin',@value = N'是否管理员',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'PositionId',@value = N'职务ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'PositionTypeGradeId',@value = N'职类职级ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'DepartmentId',@value = N'部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'OrganizationId',@value = N'机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_user add constraint t_sys_user_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_user_idx1 on t_sys_user (Account);
create index t_sys_user_idx2 on t_sys_user (Name);
go


-- Create table 用户职位信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_user_position') and type = 'U')
   drop table t_sys_user_position
go
create table t_sys_user_position
(
  ID                        varchar(50) not null,
  UserId                    varchar(50) not null,
  DepartmentPositionId      varchar(50),
  PositionId                varchar(50),
  PositionTypeGradeId       varchar(50),
  DepartmentId              varchar(50),
  OrganizationId            varchar(50),
  IsMain                    bit,
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@value = N'用户职位信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'UserId',@value = N'用户ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'DepartmentPositionId',@value = N'部门职位ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'PositionId',@value = N'职务ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'PositionTypeGradeId',@value = N'职类职级ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'DepartmentId',@value = N'部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'OrganizationId',@value = N'机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'IsMain',@value = N'是否主职',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_user_position',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_user_position add constraint t_sys_user_position_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_user_position_idx1 on t_sys_user_position (UserId,PositionId,PositionTypeGradeId,DepartmentId);
go


-- Create table web接口版本信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_webapi_version') and type = 'U')
   drop table t_sys_webapi_version
go
create table t_sys_webapi_version
(
  ID                        varchar(50) not null,
  WebApiNumbers             varchar(20),  
  WebApiId					varchar(50),
  AssemblyName				varchar(100),
  ClassName					varchar(200),
  MethodName				varchar(100),
  Version1					int,
  Version2					int,
  Version3					int,
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@value = N'接口版本信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'WebApiNumbers',@value = N'接口编号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'WebApiId',@value = N'接口ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'AssemblyName',@value = N'接口程序集名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'ClassName',@value = N'接口类名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'MethodName',@value = N'接口方法名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'Version1',@value = N'主版本号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'Version2',@value = N'次版本号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'Version3',@value = N'修订版本号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_version',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_webapi_version add constraint t_sys_webapi_version_pk primary key (ID);
go

-- Create/Recreate indexes
create index t_sys_webapi_version_idx1 on t_sys_webapi_version (WebApiId);
create index t_sys_webapi_version_idx2 on t_sys_webapi_version (WebApiNumbers);
create index t_sys_webapi_version_idx3 on t_sys_webapi_version (SortNumber);
go


-- Create table web接口信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_webapi') and type = 'U')
   drop table t_sys_webapi
go
create table t_sys_webapi
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  Numbers                   varchar(20),
  ClassifyId				varchar(50),
  IsLoginAccess				bit,
  IsAuthenticationAccess	bit,
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@value = N'接口信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'Name',@value = N'接口名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'Numbers',@value = N'接口编号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'ClassifyId',@value = N'所属分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'IsLoginAccess',@value = N'是否登录访问',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'IsAuthenticationAccess',@value = N'是否授权访问',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_webapi add constraint t_sys_webapi_pk primary key (ID);
go

-- Create/Recreate indexes
create index t_sys_webapi_idx1 on t_sys_webapi (ClassifyId);
create unique index t_sys_webapi_idx2 on t_sys_webapi (Numbers);
create index t_sys_webapi_idx3 on t_sys_webapi (SortNumber);
create index t_sys_webapi_idx4 on t_sys_webapi (Name);
go


-- Create table web接口分类信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_webapi_classify') and type = 'U')
   drop table t_sys_webapi_classify
go
create table t_sys_webapi_classify
(
  ID                        varchar(50) not null,
  Name                      varchar(50),
  ParentId                  varchar(50),
  Levels                    int,
  Code                      varchar(4),
  FullCode                  varchar(max),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@value = N'web接口信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'Name',@value = N'分类名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'ParentId',@value = N'上级分类ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'Levels',@value = N'web接口级别',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'Code',@value = N'分类编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'FullCode',@value = N'分类全编码',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_webapi_classify',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_webapi_classify add constraint t_sys_webapi_classify_pk primary key (ID);
go

-- Create/Recreate indexes
create unique index t_sys_webapi_classify_idx1 on t_sys_webapi_classify (Code);
create index t_sys_webapi_classify_idx2 on t_sys_webapi_classify (ParentId);
go


-- Create table 接口配置信息
if exists (select 1 from  sysobjects where  id = object_id('t_sys_config_webapi') and type = 'U')
   drop table t_sys_config_webapi
go
create table t_sys_config_webapi
(
  ID						varchar(50) not null,
  Name						varchar(50),
  ApplicationTypeId			int,
  APIAddress				varchar(500),
  SortNumber                int,
  IsEnable                  bit,
  CreateUserId              varchar(50),
  CreateUserName            varchar(100),
  CreateDepartmentId        varchar(50),
  CreateOrganizationId      varchar(50),
  CreateTime                datetime,
  ModifyUserId              varchar(50),
  ModifyUserName            varchar(50),
  ModifyTime                datetime,
  Remarks                   varchar(2000)
);
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@value = N'接口配置信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'Name',@value = N'应用名称',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'ApplicationTypeId',@value = N'应用类型ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'APIAddress',@value = N'接口地址',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'SortNumber',@value = N'排序号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'IsEnable',@value = N'是否启用',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_sys_config_webapi',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_sys_config_webapi add constraint t_sys_config_webapi_pk primary key (ID);
create index t_sys_config_webapi_idx1 on t_sys_config_webapi (ApplicationTypeId);
go

if exists (select 1 from sysobjects where  id = object_id('t_school_student') and type = 'U')
   drop table t_school_student
go

create table t_school_student (
   ID                   varchar(50)          not null,
   Name                 varchar(100)         null,
   Number				varchar(100)         null,
   GenderId             int                  null,
   Age                  int                  null,
   Contact              varchar(100)         null,
   ContactMobile        varchar(50)          null,
   Hobby                varchar(1000)        null,
   CampusId             varchar(50)          null,
   ClassId              varchar(50)          null,
   CreateUserId         varchar(50)          null,
   CreateUserName       varchar(100)         null,
   CreateDepartmentId   varchar(50)          null,
   CreateOrganizationId varchar(50)          null,
   CreateTime           datetime             null,
   ModifyUserId         varchar(50)          null,
   ModifyUserName       varchar(100)         null,
   ModifyTime           datetime             null,
   Remarks              varchar(2000)        null
)
go

-- Add comments to the table 
exec sys.sp_addextendedproperty @level1name = N't_school_student',@value = N'学生信息',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE'

-- Add comments to the columns 
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'ID',@value = N'主键ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'Name',@value = N'姓名',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'Number',@value = N'编号',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'GenderId',@value = N'性别ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'Age',@value = N'年龄',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'Contact',@value = N'联系人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'ContactMobile',@value = N'联系人手机',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'Hobby',@value = N'兴趣爱好',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'CampusId',@value = N'校区ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'ClassId',@value = N'班级ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'

--Add comments to the public columns
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'CreateUserId',@value = N'创建人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'CreateUserName',@value = N'创建人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'CreateDepartmentId',@value = N'创建部门ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'CreateOrganizationId',@value = N'创建机构ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'CreateTime',@value = N'创建时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'ModifyUserId',@value = N'修改人ID',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'ModifyUserName',@value = N'修改人',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'ModifyTime',@value = N'修改时间',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
exec sys.sp_addextendedproperty @level1name = N't_school_student',@level2name = N'Remarks',@value = N'备注',@name = N'MS_Description',@level0type = N'SCHEMA',@level0name = N'dbo',@level1type = N'TABLE',@level2type = N'COLUMN'
go

-- Create/Recreate primary, unique and foreign key constraints 
alter table t_school_student add constraint t_school_student_pk primary key (ID)
go